package com.akaovi.chatroom.scene;

import com.akaovi.chatroom.client.Client;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;

/**
 * @author akaovi
 * @version 1.0
 * @description 成功注册
 * @date 2022/12/9 0:23
 * @since 2022/12/9 0:23
 */
public class SuccessRegisterScene {
    static VBox vBox = new VBox();
    static Label text = new Label("注册成功");
    static int account = -1;
    static Label userAccount = new Label();
    static Button backBtn = new Button("登陆");
    static Scene successScene = new Scene(vBox, LoginScene.loginWidth, LoginScene.loginHeight);
    static Font common = new Font(18);

    static {
        text.setFont(common);
        userAccount.setFont(common);
        vBox.getChildren().addAll(text, userAccount, backBtn);
        vBox.setSpacing(20);
        vBox.setAlignment(Pos.CENTER);
        // 绑定事件
        backBtn.setOnAction(e -> {
            LoginScene.changeToLoginScene();
            account = -1;
        });
    }

    /**
     * 场景转换到成功注册
     * @param account 账号
     */
    public static void changeToSuccessRegisterScene(String account) {
        userAccount.setText(String.format("请记住您的账号: %s", account));
        Client.getStage().setScene(successScene);
    }
}
